﻿@model loveMotorcade.web.Models.carClass

@using loveMotorcade.web.Classes
@{

    ViewBag.Title = "Edit";
}
<style>

    fieldset
    {
     padding:10px;
    }
    textarea
    {
        height:100px;
        width:600px;
    }

</style>
@if(Model.name==""){
    <h2>@Model.name 信息</h2>
}else{
    <h2>新建车型信息</h2>
}

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset style="">
        <legend style=" ">外部信息</legend>

        @Html.HiddenFor(model => model.ID)

        <div class="editor-label">
            车型名
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.name)
            @Html.ValidationMessageFor(model => model.name)
        </div>

        <div class="editor-label">
            品牌
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.carBrand)
            @Html.ValidationMessageFor(model => model.carBrand)
        </div>

        <div class="editor-label">
            介绍
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.intro)
            @Html.ValidationMessageFor(model => model.intro)
        </div>
        <div class="editor-label">
            车量总数
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.totalNum)
            @Html.ValidationMessageFor(model => model.totalNum)
        </div>
        <h2>图片</h2>
        <div id="carClassPic" >
            
                            <!---上传组件部分 经过权限判断后载入---->

                <div style=" width:200px; float:left;" >
                    <script type="text/javascript" src="/Content/Components/swfupload2.2/swfupload/swfupload.js"></script>
                    <script type="text/javascript" src="/Content/Components/swfupload2.2/swfupload/handlers.js" ></script>
                    <script type="text/javascript" src="/Content/Components/swfupload2.2/swfupload/swfupload.queue.js"></script>
                    <script type="text/javascript" src="/Content/Components/swfupload2.2/swfupload/fileprogress.js"></script>
                    <div class="clearFloat"></div>
                    <div id="shopPicUpload">
                        <div class="flashUpload" id="flashUpload">
                            <div id="divStatus">0 Files Uploaded</div>
                            <fieldset class="fsUploadProgress"  id="fsUploadProgress">
                                <legend class="legend">上传队列</legend>
                            </fieldset>
                            <span  id="uploadButton">上传</span>
                            <input id="btnCancel" type="button" onclick="swfu.cancelQueue();" disabled="disabled" style=" border:0px; cursor:pointer;  font-size:12px; font-family:宋体; margin-left: 2px;  height: 20px;" value="取消" />
                            
                        </div>

                    </div>

                </div>
                <!---上传组件部分 经过权限判断后载入 end---->
                <div id="carClassPicContent">
                    @{
    var picslist = Model.pics.tryToArray(",");
                    }
                    @foreach (var p in picslist) {
                        <div style=" display:inline-block;*display:inline; zoom:1; margin:3px; position:relative">
                            <img src="/Content/upload/carClassPic/s/@(p).jpg" style="border:1px solid #fff;"  />
                            <button onclick="delpic(this,'@(p)')" style="bottom:6px; right:-6px; background:#fff; height:16px; width:16px; padding:0px; line-height:12px; position:absolute">X</button>
                        </div>
                    }
                </div>
        </div>
    </fieldset>
    <hr />
    <fieldset>
        <legend>内部资料</legend>
        <div class="editor-label">
            联系人
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.headman)
            @Html.ValidationMessageFor(model => model.headman)
        </div>

        <div class="editor-label">
            联系人叫你丫头
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.headmainPhone)
            @Html.ValidationMessageFor(model => model.headmainPhone)
        </div>

        <div class="editor-label">
            备注
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.bak)
            @Html.ValidationMessageFor(model => model.bak)
        </div>

        <div class="editor-label">
            失效
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.disable)
            @Html.ValidationMessageFor(model => model.disable)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <script>
        function delpic(it,filename) {

            var id = $("#ID").val();
            if (id == "0") {
                $("#carClassPic").hide();
                return;
            }
            $.get("/manage/carClass/delpic/"+id,{"filename":filename},function(json){
                $(it).parent().remove();
            })
        }

        function bulidFlash_shopPic(id, session) {
            //如果ID=0，既为新建carClass时不显示图片部分
            var id = $("#ID").val();
            if (id == "0") {
                $("#carClassPic").hide();
                return;
            }

            swfu = new SWFUpload({
                // Backend Settings
                upload_url: "/manage/carClass/uploadPic",
                post_params: {
                    //"ASPSESSID": session,
                    "id":id
                },

                // File Upload Settings
                file_size_limit: "2 MB",
                file_types: "*.jpg",
                file_types_description: "JPG Images",
                file_upload_limit: "0",    // Zero means unlimited

                file_queued_handler: fileQueued,
                file_queue_error_handler: fileQueueError,
                file_dialog_complete_handler: fileDialogComplete,
                upload_start_handler: uploadStart,
                upload_progress_handler: uploadProgress,
                upload_error_handler: uploadError,
                upload_success_handler: uploadSuccess,
                upload_complete_handler: uploadComplete,
                queue_complete_handler: queueComplete,



                // Button settings
                //button_image_url: "/Content/images/pictures.png",
                button_placeholder_id: "uploadButton",
                button_width: 60,
                button_height: 22,
                button_text: '<span class="button" style="background:red">选择上传</span>',
                button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12px; border:1px solid red } .buttonSmall { font-size: 10pt; }',
                button_text_top_padding: 1,
                button_text_left_padding: 5,

                // Flash Settings
                flash_url: "/Content/Components/swfupload2.2/swfupload/swfupload.swf", // Relative to this file

                custom_settings: {
                    progressTarget: "fsUploadProgress"
                    ,cancelButtonId: "btnCancel"
                },

                // Debug Settings
                debug: false
            });

            return swfu;

        }
        $(bulidFlash_shopPic);
    </script>
}
        